#version 110
uniform float nbPalier;

varying  vec4 couleur;
varying vec3 N,L,V;


void main() {
     float spec, coef; 
     float intensiteDiffus, pas;
     int i;        
     vec3 R;
    
     R = 2.0*(dot(N,L))*N - L;
     R=normalize(R);   

     coef=max(dot(V,R),0.0);

     spec = pow(coef,gl_FrontMaterial.shininess);

     intensiteDiffus = max(dot(N,L),0.0);
          
     pas = (0.95-0.25)/nbPalier;
    if((0.25 <= intensiteDiffus) && (intensiteDiffus <= 0.95)){
              intensiteDiffus = floor(intensiteDiffus/pas)*pas;
     }

     gl_FragColor=(intensiteDiffus*gl_FrontMaterial.diffuse) 
                                + (spec*gl_FrontMaterial.specular);
	 
}

